home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / dev / src / Rkm_asm.lha / Assembly_Codes / OS_Sources / Libraries / Gadtools-Menu.s next >
Text File  |  1992-09-02  |  7KB  |  446 lines

  1.  
  2.     INCDIR    WORK:Include/
  3.  
  4.     INCLUDE    exec/exec_lib.i
  5.     INCLUDE    exec/memory.i
  6.     INCLUDE    intuition/intuition_lib.i
  7.     INCLUDE    intuition/intuition.i
  8.     INCLUDE    graphics/graphics_lib.i
  9.     INCLUDE    graphics/text.i
  10.     INCLUDE dos/dos_lib.i
  11.     INCLUDE dos/dos.i
  12.     INCLUDE    workbench/icon_lib.i
  13.     INCLUDE    workbench/startup.i
  14.     INCLUDE    workbench/workbench.i
  15.     INCLUDE    libraries/gadtools_lib.i
  16.     INCLUDE    libraries/gadtools.i
  17.  
  18.     INCLUDE    misc/easystart.i
  19.  
  20. LIB_VER        EQU    39
  21. TRUE        EQU    -1
  22. FALSE        EQU    0
  23. FILE_SIZE    EQU    100
  24.  
  25.     moveq    #LIB_VER,d0
  26.     lea    dos_name(pc),a1
  27.     move.l    4.w,a6
  28.     jsr    _LVOOpenLibrary(a6)
  29.     move.l    d0,_DOSBase
  30.     beq    exit_quit
  31.  
  32.     moveq    #LIB_VER,d0
  33.     lea    int_name(pc),a1
  34.     jsr    _LVOOpenLibrary(a6)
  35.     move.l    d0,_IntuitionBase
  36.     beq    exit_closedos
  37.  
  38.     moveq    #LIB_VER,d0
  39.     lea    gfx_name(pc),a1
  40.     jsr    _LVOOpenLibrary(a6)
  41.     move.l    d0,_GfxBase
  42.     beq    exit_closeint
  43.  
  44.     moveq    #LIB_VER,d0
  45.     lea    gt_name(pc),a1
  46.     jsr    _LVOOpenLibrary(a6)
  47.     move.l    d0,_GadtoolsBase
  48.     beq    exit_closegfx
  49.  
  50.     moveq    #LIB_VER,d0
  51.     lea    icon_name(pc),a1
  52.     jsr    _LVOOpenLibrary(a6)
  53.     move.l    d0,_IconBase
  54.     beq    exit_closegadtools
  55.  
  56.     suba.l    a0,a0
  57.     CALLINT    LockPubScreen
  58.     move.l    d0,scrnptr
  59.     beq    exit_closeicon
  60.  
  61.     move.l    scrnptr(pc),a0
  62.     suba.l    a1,a1
  63.     move.l    _GadtoolsBase(pc),a6
  64.     jsr    _LVOGetVisualInfoA(a6)
  65.     move.l    d0,vis
  66.     beq    unlock_pubscreen
  67.  
  68.     lea    newmenu0(pc),a0
  69.     lea    newmenu0tags(pc),a1
  70.     jsr    _LVOCreateMenusA(a6)
  71.     move.l    d0,menustrip
  72.     beq    free_visual
  73.  
  74.     move.l    d0,a0
  75.     move.l    vis(pc),a1
  76.     lea    newmenu0tags(pc),a2
  77.     jsr    _LVOLayoutMenusA(a6)
  78.     tst.l    d0
  79.     beq    free_menustrip
  80.  
  81.     bsr    unlock_ps
  82.     move.b    #1,scrlock
  83.  
  84.     lea    wndwdefs(pc),a0
  85.     CALLINT    OpenWindow
  86.     move.l    d0,wndwptr
  87.     beq    free_menustrip
  88.  
  89.     move.l    wndwptr,a0
  90.     move.l    wd_RPort(a0),wndwrp
  91.  
  92.     move.l    wndwptr(pc),a0
  93.     move.l    menustrip(pc),a1
  94.     CALLINT    SetMenuStrip
  95.     tst.l    d0
  96.     beq    close_window
  97.  
  98.     CALLGRAF    WaitTOF
  99.  
  100.     move.l    wndwptr(pc),a0
  101.     suba.l    a1,a1
  102.     CALLGADTOOLS    GT_RefreshWindow
  103.  
  104. mainloop
  105.     move.l    wndwptr(pc),a0
  106.     move.l    wd_UserPort(a0),a0
  107.     move.l    4.w,a6
  108.     jsr    _LVOWaitPort(a6)
  109.     move.l    wndwptr(pc),a0
  110.     move.l    wd_UserPort(a0),a0
  111.     move.l    _GadtoolsBase(pc),a6
  112.     jsr    _LVOGT_GetIMsg(a6)
  113.     move.l    d0,a1
  114.     move.l    im_Class(a1),iclass
  115.     move.w    im_Code(a1),icode
  116.     move.w    im_Qualifier(a1),iqual
  117.     move.l    im_IAddress(a1),iadr
  118.     move.w    im_MouseX(a1),msex
  119.     move.w    im_MouseY(a1),msey
  120.     jsr    _LVOGT_ReplyIMsg(a6)
  121.  
  122.     move.l    iclass,d0
  123.  
  124.     cmp.l    #IDCMP_GADGETUP,d0
  125.     beq    which_gadgetup
  126.  
  127.     cmp.l    #IDCMP_GADGETDOWN,d0
  128.     beq    which_gadgetdown
  129.  
  130.     cmp.l    #IDCMP_VANILLAKEY,d0
  131.     beq    which_vanillakey
  132.  
  133.     cmp.l    #IDCMP_RAWKEY,d0
  134.     beq    which_rawkey
  135.  
  136.     cmp.l    #IDCMP_MOUSEBUTTONS,d0
  137.     beq    which_mousebutton
  138.  
  139.     cmp.l    #IDCMP_MENUPICK,d0
  140.     beq    which_menu
  141.  
  142.     cmp.l    #IDCMP_MENUHELP,d0
  143.     beq    which_menu
  144.  
  145.     cmp.l    #IDCMP_REFRESHWINDOW,d0
  146.     beq    refresh_window
  147.  
  148.     cmp.l    #IDCMP_INACTIVEWINDOW,d0
  149.     beq    window_inactive
  150.  
  151.     cmp.l    #IDCMP_ACTIVEWINDOW,d0
  152.     beq    window_active
  153.  
  154.     cmp.l    #IDCMP_CLOSEWINDOW,d0
  155.     beq.s    clear_menustrip
  156.  
  157.     bra    mainloop
  158.  
  159. clear_menustrip
  160.     move.l    wndwptr(pc),a0
  161.     CALLINT    ClearMenuStrip
  162.  
  163. close_window
  164.     move.l    wndwptr(pc),a0
  165.     CALLINT    CloseWindow
  166.  
  167. free_menustrip
  168.     move.l    menustrip,a0
  169.     CALLGADTOOLS    FreeMenus
  170.  
  171. free_visual
  172.     move.l    vis(pc),a0
  173.     CALLGADTOOLS    FreeVisualInfo
  174.  
  175. unlock_pubscreen
  176.     tst.b    scrlock
  177.     bne.s    exit_closeicon
  178.     bsr    unlock_ps
  179.  
  180. exit_closeicon
  181.     move.l    _IconBase(pc),a1
  182.     CALLEXEC    CloseLibrary
  183.  
  184. exit_closegadtools
  185.     move.l    _GadtoolsBase(pc),a1
  186.     CALLEXEC    CloseLibrary
  187.  
  188. exit_closegfx
  189.     move.l    _GfxBase(pc),a1
  190.     CALLEXEC    CloseLibrary
  191.  
  192. exit_closeint
  193.     move.l    _IntuitionBase(pc),a1
  194.     CALLEXEC    CloseLibrary
  195.  
  196. exit_closedos
  197.     move.l    _DOSBase(pc),a1
  198.     CALLEXEC    CloseLibrary
  199.  
  200. exit_quit
  201.     moveq    #0,d0
  202.     rts
  203.  
  204.  
  205.  * Jump-To Routines.
  206.  
  207. which_gadgetup
  208.  
  209.     bra    mainloop
  210.  
  211. which_upid
  212.  
  213.     bra    mainloop
  214.  
  215. which_gadgetdown
  216.  
  217.     bra    mainloop
  218.  
  219. which_downid
  220.  
  221.     bra    mainloop
  222.  
  223. which_vanillakey
  224.  
  225.     bra    mainloop
  226.  
  227. which_rawkey
  228.  
  229.     bra    mainloop
  230.  
  231. which_brownkey
  232.  
  233.     bra    mainloop
  234.  
  235. which_mousebutton
  236.  
  237.     bra    mainloop
  238.  
  239.  * Menu numbers are 16 bits.
  240.  *
  241.  * Bits 0-4   = menu number (on the title bar).
  242.  * Bits 5-10  = menu-item number.
  243.  * Bits 11-15 = sub-item number.
  244.  *
  245.  * The bits are given the following values:
  246.  *
  247.  * Bits 15-11      Bits 10-5       Bits 4-0
  248.  *
  249.  * 16 8 4 2 1    32 16 8 4 2 1    16 8 4 2 1
  250.  *
  251.  * Any bits pairs (15-11, 10-5 and 4-0) that have all their bits set is
  252.  * classed as no selection (no number) for that menu/menu-item/sub-item.
  253.  * So. F8 (bits 15-11 set) below means no sub-item.
  254.  
  255. which_menu
  256.     move.w    icode,d0
  257.     cmp.w    #$F800,d0    ; 11111 000000 00000
  258.     beq.s    do_nothing
  259.     cmp.w    #$F820,d0    ; 11111 000001 00000
  260.     beq.s    do_nothing
  261.     cmp.w    #$0040,d0    ; 00000 000010 00000
  262.     beq.s    do_nothing
  263.     cmp.w    #$0840,d0    ; 00001 000010 00000
  264.     beq.s    do_nothing
  265.     cmp.w    #$F8A0,d0    ; 11111 000110 00000
  266.     beq    clear_menustrip
  267.     bra    mainloop
  268.  
  269. do_nothing
  270.     bra    mainloop
  271.  
  272. refresh_window
  273.     bsr.s    begin_refresh
  274.  
  275.     bsr.s    end_refresh
  276.  
  277.     bra    mainloop
  278.  
  279. window_inactive
  280.  
  281.     bra    mainloop
  282.  
  283. window_active
  284.  
  285.     bra    mainloop
  286.  
  287.  
  288.  * Sub-Routines.
  289.  
  290. unlock_ps
  291.     suba.l    a0,a0
  292.     move.l    scrnptr(pc),a1
  293.     CALLINT    UnlockPubScreen
  294.     rts
  295.  
  296. begin_refresh
  297.     move.l    wndwptr,a0
  298.     CALLGADTOOLS    GT_BeginRefresh
  299.     rts
  300.  
  301. end_refresh
  302.     move.l    wndwptr,a0
  303.     moveq    #-1,d0
  304.     CALLGADTOOLS    GT_EndRefresh
  305.     rts
  306.  
  307.  
  308.  * Structure Definitions.
  309.  
  310. newmenu0
  311.     dc.b    NM_TITLE,0
  312.     dc.l    mmstg0,0
  313.     dc.w    0
  314.     dc.l    0,0
  315.  
  316.     dc.b    NM_ITEM,0
  317.     dc.l    mistg0,lkey
  318.     dc.w    0
  319.     dc.l    0,0
  320.  
  321.     dc.b    NM_ITEM,0
  322.     dc.l    mistg1,skey
  323.     dc.w    0
  324.     dc.l    0,0
  325.  
  326.     dc.b    NM_ITEM,0
  327.     dc.l    NM_BARLABEL,0
  328.     dc.w    0
  329.     dc.l    0,0
  330.  
  331.     dc.b    NM_ITEM,0
  332.     dc.l    mistg2,0
  333.     dc.w    0
  334.     dc.l    0,0
  335.  
  336.     dc.b    NM_SUB,0
  337.     dc.l    sistg0,akey
  338.     dc.w    0
  339.     dc.l    0,0
  340.  
  341.     dc.b    NM_SUB,0
  342.     dc.l    sistg1,pkey
  343.     dc.w    0
  344.     dc.l    0,0
  345.  
  346.     dc.b    NM_ITEM,0
  347.     dc.l    NM_BARLABEL,0
  348.     dc.w    0
  349.     dc.l    0,0
  350.  
  351.     dc.b    NM_ITEM,0
  352.     dc.l    mistg3,qkey
  353.     dc.w    0
  354.     dc.l    0,0
  355.  
  356.     dc.b    NM_END,0
  357.     dc.l    0,0
  358.     dc.w    0
  359.     dc.l    0,0
  360.  
  361. topaz9
  362.     dc.l    font_name
  363.     dc.w    9
  364.     dc.b    FS_NORMAL,FPF_ROMFONT
  365.  
  366. newmenu0tags
  367.     dc.l    GTMN_TextAttr,topaz9
  368.     dc.l    0
  369.  
  370. wndwtags
  371.     dc.l    WA_MenuHelp,TRUE
  372.     dc.l    0
  373.  
  374. wndwdefs
  375.     dc.w    0,14,640,200
  376.     dc.b    0,1
  377.     dc.l    IDCMP_GADGETUP!IDCMP_GADGETDOWN!IDCMP_VANILLAKEY!IDCMP_RAWKEY!IDCMP_MOUSEBUTTONS!IDCMP_CLOSEWINDOW!IDCMP_MENUPICK!IDCMP_MENUHELP!IDCMP_REFRESHWINDOW!IDCMP_NEWSIZE!IDCMP_SIZEVERIFY!IDCMP_INACTIVEWINDOW!IDCMP_ACTIVEWINDOW
  378.     dc.l    WFLG_NW_EXTENDED!WFLG_SIMPLE_REFRESH!WFLG_SIZEGADGET!WFLG_SIZEBBOTTOM!WFLG_ACTIVATE!WFLG_CLOSEGADGET!WFLG_DRAGBAR!WFLG_DEPTHGADGET
  379.     dc.l    0,0,wndw_title,0,0
  380.     dc.w    320,100,640,200,WBENCHSCREEN
  381.     dc.l    wndwtags
  382.  
  383.  
  384.  * Long Variables.
  385.  
  386. _IntuitionBase    dc.l    0
  387. _GfxBase    dc.l    0
  388. _DOSBase    dc.l    0
  389. _IconBase    dc.l    0
  390. _UtilityBase    dc.l    0
  391. _GadtoolsBase    dc.l    0
  392. scrnptr        dc.l    0
  393. vpptr        dc.l    0
  394. cmptr        dc.l    0
  395. wndwptr        dc.l    0
  396. wndwrp        dc.l    0
  397. iclass        dc.l    0
  398. iadr        dc.l    0
  399. vis        dc.l    0
  400. glistptr    dc.l    0
  401. menustrip    dc.l    0
  402.  
  403.  
  404.  * Word Variables.
  405.  
  406. icode        dc.w    0
  407. iqual        dc.w    0
  408. msex        dc.w    0
  409. msey        dc.w    0
  410.  
  411.  * Byte Variables.
  412.  
  413. scrlock        dc.b    0
  414.  
  415.  
  416.  * String Variables.
  417.  
  418. int_name    dc.b    'intuition.library',0
  419. dos_name    dc.b    'dos.library',0
  420. icon_name       dc.b    'icon.library',0,0
  421. gfx_name    dc.b    'graphics.library',0
  422. diskfont_name    dc.b    'diskfont.library',0,0
  423. gt_name        dc.b    'gadtools.library',0,0
  424. wndw_title    dc.b    'Gadtools_Menu.s',0
  425. font_name    dc.b    'topaz.font',0,0
  426. mmstg0        dc.b    'PROJECT',0
  427. mistg0        dc.b    'Load',0,0
  428. mistg1        dc.b    'Save',0,0
  429. mistg2        dc.b    'About',0
  430. sistg0        dc.b    'This Program',0,0
  431. sistg1        dc.b    'John White',0,0
  432. mistg3        dc.b    'Quit',0,0
  433. lkey        dc.b    'L',0
  434. skey        dc.b    'S',0
  435. akey        dc.b    'A',0
  436. pkey        dc.b    'P',0
  437. qkey        dc.b    'Q',0
  438.  
  439.  
  440.     SECTION    VERSION,DATA
  441.  
  442.     dc.b    '$VER: Gadtools_Menu.s V1.01 (22.4.2001)',0
  443.  
  444.  
  445.     END
  446.